package cn.enited.devtools.apiaggregator.validator;

import cn.enited.devtools.apiaggregator.anno.IsBizId;
import cn.enited.devtools.apiaggregator.utils.NumUtil;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Objects;

public class ValidateBizId implements ConstraintValidator<IsBizId, Long> {
    @Override
    public void initialize(IsBizId constraintAnnotation) {

    }

    @Override
    public boolean isValid(Long id, ConstraintValidatorContext constraintValidatorContext) {
        if (Objects.isNull(id)) {
            return true;
        }
        return NumUtil.isValidId(id);
    }
}
